package xin.qixia.robot.ding.convert;

import xin.qixia.robot.core.convert.MessageConverter;
import xin.qixia.robot.core.domain.RobotMessage;
import xin.qixia.robot.ding.domain.DingTalkMessage;

/**
 * 消息转换
 *
 * @author wangkaixin
 * @date 2025/5/23 16:20
 */
public class DingTalkMessageConvert implements MessageConverter<DingTalkMessage> {

    @Override
    public RobotMessage convert(DingTalkMessage dingTalkMessage) {
        RobotMessage robotMessage = new RobotMessage();
        robotMessage.setAccount(dingTalkMessage.getRobotAccount());
        robotMessage.setName(dingTalkMessage.getRobotName());
        robotMessage.setGroupId(dingTalkMessage.getConversationId());
        robotMessage.setGroupName(dingTalkMessage.getConversationTitle());
        robotMessage.setSenderId(dingTalkMessage.getSenderStaffId());
        robotMessage.setSenderName(dingTalkMessage.getSenderNick());
        robotMessage.setSendTime(dingTalkMessage.getCreateAt());
        robotMessage.setType(dingTalkMessage.getMsgType());
        robotMessage.setContent(dingTalkMessage.getText().getContent());
        return robotMessage;
    }
}
